package com.cos.emp.web.controller;

import com.cos.emp.common.Const;
import com.cos.emp.entity.Emp;
import com.cos.emp.services.EmpServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author: COS
 * @time: 2022/9/30 15:08
 * @description:
 */
@Controller
public class SystemController {

    @Autowired
    private EmpServices empServices;

    @RequestMapping("/login")
    public String login(String ename, String pwd, HttpSession session) {
        Emp emp = empServices.doLogin(ename, pwd);
        if (emp != null) {
            session.setAttribute(Const.IS_LOGIN, emp);
            return "redirect:/emp/getEmpByPage";
        }
        return "redirect:/login.jsp";
    }

}
